﻿using System;
using Glimpse.Core.Framework;


namespace GlimpseWcf.Server
{
    public class WcfRequestMetadata : IRequestMetadata
    {
        public WcfRequestMetadata(OperationContextWrapper context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            Context = context;
        }

        public string RequestHttpMethod
        {
            get { return "WCF"; }
        }

        public int ResponseStatusCode
        {
            get { return 200; }
        }

        public string ResponseContentType
        {
            get { return "text/html"; }
        }

        public string IpAddress
        {
            get { return ""; }
        }

        public bool RequestIsAjax
        {
            get { return false; }
        }

        public string ClientId
        {
            get { return Guid.NewGuid().ToString("N"); }
        }

        public string RequestUri
        {
            get { return ""; }
        }

        private OperationContextWrapper Context { get; set; }

        public string GetHttpHeader(string name)
        {
            return "";
        }

        public string GetCookie(string name)
        {
            var httpCookie = Context.Cookies[name];
            return httpCookie != null ? httpCookie.Value : string.Empty;
        }
    }
}
